package com.nwpu.main;

import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import java.io.IOException;

/**
 * 自定义选择标签
 * 
 * @author liyong
 *
 */
// public class CreateSelectTag extends TagSupport {
//
// 	public int doStartTag() throws JspException {
// 		try {
// 			JspWriter out = pageContext.getOut();
// 			String outPrint = "";
// 			String[] color = { "light", "amber", "brown", "dark" };
// 			outPrint += "<select name='color' size='1'>";
// 			for (int i = 0; i < color.length; i++) {
// 				outPrint += "<option>";
// 				outPrint += color[i];
// 				outPrint += "</option>";
// 			}
// 			outPrint += "</select>";
// 			out.print(outPrint);
// 		} catch (java.io.IOException e) {
// 			throw new JspTagException(e.getMessage());
// 		}
// 		return SKIP_BODY;
// 	}
// }

public class CreateSelectTag extends SimpleTagSupport{
	@Override
	public void doTag() throws JspException, IOException {
		try {
			JspWriter out = getJspContext().getOut();
			String outPrint = "";
			String[] color = { "light", "amber", "brown", "dark" };
			outPrint += "<select name='color' size='1'>";
			for (int i = 0; i < color.length; i++) {
				outPrint += "<option>";
				outPrint += color[i];
				outPrint += "</option>";
			}
			outPrint += "</select>";
			out.print(outPrint);
		} catch (java.io.IOException e) {
			throw new JspTagException(e.getMessage());
		}
	}
}